package com.tdrc.common.exception;

import com.tdrc.common.beans.ResultCode;

import java.text.MessageFormat;

/**
 * @author dpf
 * @version 1.0
 * @date 2020-4-14 11:16
 * @instruction ...
 */
public class CustomException extends RuntimeException {
    //错误代码
    ResultCode resultCode;

    public CustomException(ResultCode resultCode){
        super(resultCode.msg());
        this.resultCode = resultCode;
    }

    public CustomException(ResultCode resultCode, Object... args){
        String message = MessageFormat.format(resultCode.msg(), args);
        resultCode.setMsg(message);
        this.resultCode = resultCode;
    }

    public ResultCode getResultCode(){
        return resultCode;
    }
}
